package ipc;

public class postSolve{
	public double avgR;
	public double varR;
	
	public  long sizeofV;
	public long sizeofpi;
	
	public double timetoplay;
	public double timetosolve;
	
	public String toInsert(int runid){
		StringBuffer sb = new StringBuffer();
		sb.append("INSERT INTO POSTSOLVE VALUES (");
		sb.append(runid);
		sb.append(", ");
		sb.append(avgR);
		sb.append(", ");
		sb.append(varR);
		sb.append(", ");
		sb.append(sizeofV);
		sb.append(", ");
		sb.append(sizeofpi);
		sb.append(", ");
		sb.append(timetosolve);
		sb.append(", ");
		sb.append(timetoplay);
		sb.append(")");
		
		return sb.toString();
	}

	public postSolve(double avgR, double varR, long sizeofV, long sizeofpi, double timetoplay, double timetosolve) {
		super();
		this.avgR = avgR;
		this.varR = varR;
		this.sizeofV = sizeofV;
		this.sizeofpi = sizeofpi;
		this.timetoplay = timetoplay;
		this.timetosolve = timetosolve;
	}
	
	public postSolve() {
		this.avgR = 0;
		this.varR = 0;
		this.sizeofV = 0;
		this.sizeofpi = 0;
		this.timetoplay = 0;
		this.timetosolve = 0;
	}

	public void addPostSolve(postSolve ps){
		avgR += ps.avgR;
		varR += ps.varR;
		sizeofpi += ps.sizeofpi;
		sizeofV += ps.sizeofV;
		timetoplay += ps.timetoplay;
		timetosolve += ps.timetosolve;
	}
	
	public void finishUp(int nRuns){
		avgR /= nRuns;
		varR /= nRuns;
		sizeofpi /= nRuns;
		sizeofV /= nRuns;
		timetoplay /= nRuns;
		timetosolve /= nRuns;
	}

	@Override
	public String toString() {
		return "postSolve [avgR=" + this.avgR + ", varR=" + this.varR
				+ ", sizeofV=" + this.sizeofV + ", sizeofpi=" + this.sizeofpi
				+ ", timetoplay=" + this.timetoplay + ", timetosolve="
				+ this.timetosolve + "]";
	}
	
}